<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            padding: 20px;
        }
        .active{
            background-color: red;
        }
    </style>
</head>
<body>
    <div id="box">
        <div v-for="(value,index) in arr" :key="index" @click="get(index)" :class="isIndex==index?'active':''">{{value}}</div>
    </div>
    <script src="../vue.js"></script>
    <script>
        let box = new Vue({
            el : '#box',
            data : {
                arr : ['北京','上海','广东','深圳','青岛'],
                isIndex : 0,
            },
            methods : {
                get(index){
                    this.isIndex = index
                }
            }
        })
    </script>
</body>
</html>